package com.leetcode;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
 * Given an index k, return the kth row of the Pascal's triangle.

For example, given k = 3,
Return [1,3,3,1]

 * @author Adiy
 *
 */
public class PascalsTriangleII {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int m=in.nextInt();
	    List<Integer> result=getRow(m);
		System.out.println(result);

	}

    public static List<Integer> getRow(int rowIndex) {
    	 List<List<Integer>>   results=new ArrayList<List<Integer>>();
    	 List<Integer> listone=new ArrayList<Integer>();
    	 listone.add(1);
    	 results.add(listone);
    	 if(rowIndex==0) return listone;

	     for(int i=1;i<rowIndex+1;i++){
	    	 List<Integer> list=new ArrayList<Integer>();
	    	 list.add(0,1);
   		 
	    	 int j=1;
	    	 while(j<=i&&j<results.get(i-1).size()){
	    		
	    		 list.add(j, results.get(i-1).get(j-1)+results.get(i-1).get(j));
	    		 j++;
	    	 }
	    	 list.add(i,1);
	    	 results.add(list);
	     }
	     
	    return results.get(rowIndex);
    }
}
